package fruitsManage;

import java.util.ArrayList;
import java.util.Scanner;

public class Purchase {

	static ArrayList<PurchaseModel> purchase = new ArrayList<PurchaseModel>();// 进货记录

	static Scanner scanner = new Scanner(System.in);

	public void list() {
		PurchaseModel purchaseModel = new PurchaseModel();
		while (true) {

			System.out.println();
			System.out.println("=========请选择========");
			System.out.println("=========1-所有进货记录==");
			System.out.println("=========2-查询进货记录==");
			System.out.println("=========3-进货========");
			System.out.println("=========4-退出========");

			int key = 4;
			
			try {
				key = Integer.parseInt(scanner.nextLine());
			} catch (Exception e) {
			}
			
			if (key == 4)
				break;

			switch (key) {
			case 1:
				purchaseModel.selectAll();
				break;
			case 2:
				System.out.print("请输入水果名：");
				String name = scanner.nextLine();
				purchaseModel.selectByName(name);
				break;
			case 3:
				purchase();
				break;
			default:
				break;
			}
			System.out.println("点击回车继续...");
			scanner.nextLine();
		}
	}

	/**
	 * 进货
	 */
	public void purchase() {

		PurchaseModel purchaseModel = new PurchaseModel();

		System.out.println("=================");
		System.out.print("请输入水果名：");
		String name = scanner.nextLine();

		System.out.print("请输入库存：");
		double stock = Double.parseDouble(scanner.nextLine());

		System.out.print("请输入售价：");
		double price = Double.parseDouble(scanner.nextLine());

		System.out.print("请输入进价：");
		double bid = Double.parseDouble(scanner.nextLine());
		Fruits.bidTotal += bid * stock;

		System.out.println("=================");
		System.out.println();

		purchaseModel.addShop(name, stock, price, bid);

	}
}
